<?php

namespace App\Validators\Buz;

use Illuminate\Contracts\Validation\Factory;
use \Prettus\Validator\Contracts\ValidatorInterface;
use \Prettus\Validator\LaravelValidator;

class AuthValidator extends LaravelValidator
{



    protected $attributes = [
        'token' => '注册token',
        'password' => '用户密码',
        'trade_pwd' => '交易密码',
        'qq' => 'qq号',
        'contact' => '联系人姓名',
        'captcha' => '验证码',
        'username' => '账户名'
    ];

    protected $messages = [
        'captcha.captcha' => '验证码无效'
    ];

    public function __construct(\Illuminate\Contracts\Validation\Factory $validator)
    {
        parent::__construct($validator);
        $this->rules = [
            'register' => [
                'token' => 'required|max:32',
                'password' => 'required|max:32|min:5',
                'trade_pwd' => 'required|max:32|min:6|different:password',
                'qq' => 'required|max:20',
                'contact' => 'required|max:100',
            ],
        ];
        $login = ['username' => 'required|exists:plat_users,username'];
        $login += config('app.website.API_DEBUG') ? [] : ['captcha' => 'required|captcha'];
        $this->rules += ['login' => $login];
    }
}
